﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using MyLib;
using System.Web;

using Portal.Entity;
using Portal.Interface;

namespace Portal.Logic
{
    /// <summary>
    /// 菜单逻辑类
    /// </summary>
    public class MenuLogic
    {
        ResourceLogic _resource = new ResourceLogic();
        /// <summary>
        /// 获取菜单列表
        /// </summary>
        /// <param name="parentId">父ID</param>
        /// <param name="loginName">登录名</param>
        /// <returns>菜单列表</returns>
        public List<ResourceEntity> GetMenuList(int parentId,string loginName)
        {
            SecurityLogic security = new SecurityLogic();
            List<ResourceEntity> list = security.GetSecurityList(loginName);
            return list.FindAll(p => p.PARENTID==parentId);
        }

        /// <summary>
        /// 获取所有菜单列表
        /// </summary>
        /// <returns>所有菜单列表</returns>
        public List<ResourceEntity> GetMenuList()
        {
            List<ResourceEntity> list = _resource.GetResourceList();
            return list.FindAll(p => p.TYPE == "Menu" );
        }

        /// <summary>
        /// 获取默认菜单
        /// </summary>
        /// <param name="loginName">登录名</param>
        /// <returns>默认菜单</returns>
        public ResourceEntity GetDefaultMenu(string loginName)
        {
            List<ResourceEntity> list = _resource.GetResourceList();
            return list.Find(p => p.TYPE == "Menu" && p.EXT03 == "1");
        }

    }
}
